    //
//  SwitchViewController.m
//  _2010WorldCupNationalAthem
//
//  Created by Apple on 2010/7/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SwitchViewController.h"
#import "logoViewController.h"
#import "MainMenuViewController.h"


@implementation SwitchViewController


@synthesize logoView ;  
@synthesize mainMenuView ;

//**********************************************************
// Privtate method:  initView
//
//**********************************************************
-(void)initView
{
	
	if(self.logoView == nil)
	{  
		self.logoView = [[logoViewController alloc]initWithNibName:@"logoView" bundle:nil];  
	}  
	[self removeAllView];  
	[self.view insertSubview:self.logoView.view atIndex:0];  
	
	
	/*
	if(self.mainMenuView == nil)
	{  
		self.mainMenuView = [[MainMenuViewController alloc]initWithNibName:@"MainMenuView" bundle:nil];  
	}  
	[self removeAllView];  
	[self.view insertSubview:self.mainMenuView.view atIndex:0];  
	 */
}


//**********************************************************
// Privtate method:  removeAllView
//
//**********************************************************
-(void)removeAllView
{
	
	for(NSInteger i=0;i<[self.view.subviews count];i++)
	{  
		[[self.view.subviews objectAtIndex:i] removeFromSuperview];  
	}  	
	
}


//**********************************************************
// Privtate method:  showLogoView
//
//**********************************************************
-(void)showLogoView
{
	if(self.logoView == nil)
	{  
		// load logoView.xib
		self.logoView = [[logoViewController alloc]initWithNibName:@"logoView" bundle:nil];  
	}  
	[self removeAllView];  
	[self.view insertSubview:self.logoView.view atIndex:0];  
	
}


//**********************************************************
// Privtate method:  showMainMenuView
//
//**********************************************************
-(void)showMainMenuView
{
	if(self.mainMenuView == nil)
	{  
		// load MainMenuView.xib
		self.mainMenuView = [[MainMenuViewController alloc]initWithNibName:@"MainMenuView" bundle:nil];  
	}  
	[self removeAllView];  
	[self.view insertSubview:self.mainMenuView.view atIndex:0]; 		
	
}




/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[logoView release] ;
	[mainMenuView release] ;
    [super dealloc];
}


@end
